package com.yanqu.road.server.cmd.activity.newyearbag;

import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.common.CommonProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.newyearbag.NewYearBagMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = GameProtocol.S_NEW_YEAR_BAG_SHARE, desc = "活动分享")
public class NewYearBagShareCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        if (!ActivityMgr.activityInTime(NewYearBagMgr.getActivityInfo())) {
            ret = GameErrorCode.E_ACTIVITY_OVER_TIME;
            return;
        }
        player.notifyListener(eGamePlayerEventType.NewYearBagShare.getValue(), 1);
    }

    @Override
    public void sendData(GamePlayer player) {
        player.sendPacket(Protocol.U_NEW_YEAR_BAG_SHARE, CommonProto.ResultValueMsg.newBuilder().setRet(ret));
    }
}
